fix(integrations): cursor-agent honors executable/extra-args env overrides#3265
Conversation
…rrides cursor-agent's build_exec_args() hardcoded self.key as argv[0] and never called _apply_extra_args_env_var(), so the documented SPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLE (issue github#2596) and SPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGS (issue github#2595) hooks were silently dropped — unlike every other CLI-dispatch integration (codex, devin). Route argv[0] through _resolve_executable() and apply the extra-args hook after the mandatory headless flags, mirroring the twins. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes parity for the cursor-agent integration by ensuring it honors the same documented per-integration environment-variable hooks as other CLI-dispatch integrations (notably executable override and extra CLI args injection).
Changes:
- Route
CursorAgentIntegrationargv[0] throughself._resolve_executable()soSPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLEis honored. - Invoke
self._apply_extra_args_env_var(args)inCursorAgentIntegration.build_exec_args()soSPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGSis applied. - Add targeted tests validating both overrides for
cursor-agent.
Show a summary per file
| File | Description |
|---|---|
| src/specify_cli/integrations/cursor_agent/init.py | Uses _resolve_executable() and _apply_extra_args_env_var() to honor executable and extra-args env overrides in cursor-agent CLI dispatch. |
| tests/integrations/test_integration_cursor_agent.py | Adds tests for executable override and extra args injection for cursor-agent build_exec_args(). |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Low
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback
Per Copilot feedback: the extra-args override test only asserted the injected tokens were present, not that they land before Spec Kit's canonical --model / --output-format flags. Exercise build_exec_args with both a model and JSON output and assert the extra args are inserted before --model / --output-format (and the canonical flags stay intact and paired). Verified this fails if the _apply_extra_args_env_var call is moved after the flag extends. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Thanks @mnriem — addressed the Copilot feedback in |
|
Thank you! |
Description
Spec Kit exposes two documented per-integration env hooks on every CLI-dispatch integration:
SPECKIT_INTEGRATION_<KEY>_EXECUTABLE— pin the binary path (issue feat(integrations): support SPECIFY_<KEY>_EXTRA_ARGS env var for agent subprocess flags #2596), via_resolve_executable().SPECKIT_INTEGRATION_<KEY>_EXTRA_ARGS— inject extra flags into the spawned agent (issue [Feature]: Inject extra CLI flags into the agent subprocess via env var #2595), via_apply_extra_args_env_var().codexanddevinboth route through these helpers:But
CursorAgentIntegration.build_exec_args()hardcodedself.keyas argv[0] and never called_apply_extra_args_env_var():So
SPECKIT_INTEGRATION_CURSOR_AGENT_EXECUTABLEandSPECKIT_INTEGRATION_CURSOR_AGENT_EXTRA_ARGSwere silently ignored for cursor-agent — the lone CLI-dispatch outlier.Fix
Route argv[0] through
self._resolve_executable()and apply the extra-args hook immediately after the mandatory headless flags (before the--model/--output-formatextends), mirroring codex/devin. The mandatory-p --trust --approve-mcps --forceflags are unchanged.Testing
test_build_exec_args_honors_executable_overrideandtest_build_exec_args_honors_extra_args_override: fail before (argv[0]==cursor-agent, no--foo), pass after (verified by stashing the source — both fail). The mandatory-flags assertion still holds under the override.cursor-agentonly in the default no-env case (where_resolve_executable()falls back toself.key), so they stay green.TestCursorAgentCliDispatchpasses (12);uvx ruff checkclean.AI Disclosure
Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI flagged the codex/devin-vs-cursor-agent parity gap; I confirmed the dropped overrides, proved fail-before via source-stash, and reviewed the diff before submitting.